<template>
  <div class="page-home">
    <div class="home-entry">
      <div class="container">
        <!-- 左侧分类 -->
        <HomeCategory />
        <!-- banner轮播图 -->
        <HomeBanner />
        <!-- 新鲜好物 -->
        <home-pannel title="新鲜好物" sub-title="新鲜出炉 品质靠谱">
          <template #right>
            <xtx-more></xtx-more>
          </template>
          <template #main>
            <ul ref="pannel" class="goods-list">
              <li v-for="item in newData" :key="item.id">
                <RouterLink :to="`/good/${item.id}`">
                  <img :src="item.picture" alt="" />
                  <p class="name">{{ item.name }}</p>
                  <p class="price">&yen;{{ item.price }}</p>
                </RouterLink>
              </li>
            </ul>
          </template>
        </home-pannel>
        <!-- 人气推荐  -->
        <home-pannel title="人气推荐" sub-title="人气推荐 不容错过">
          <template #main>
            <ul class="goods-list">
              <li v-for="item in hotData" :key="item.id">
                <RouterLink to="/">
                  <img alt="" v-img-lazy="item.picture" />
                  <p class="name">{{ item.title }}</p>
                  <p class="desc">{{ item.alt }}</p>
                </RouterLink>
              </li>
            </ul>
          </template>
        </home-pannel>
        <!-- 品牌 -->
        <home-pannel title="热门品牌" sub-title="国际经典 品质保障">
          <template #main>
            <ul class="brand-list">
              <li v-for="item in brandData" :key="item.id">
                <img :src="item.picture" alt="">
              </li>
            </ul>
          </template>
        </home-pannel>
      </div>
    </div>
  </div>
</template>

<script>
import HomeCategory from './components/home-category.vue'
import HomeBanner from './components/home-banner.vue'
import HomePannel from './components/home-pannel.vue'

import { useNew } from './service/useNew'
import { useHot } from './service/useHot'
import { useBrand } from './service/useBrand'

export default {
  components: {
    HomeCategory,
    HomeBanner,
    HomePannel
  },
  setup () {
    // 新鲜好物
    const { newData } = useNew()
    // 人气推荐
    const { hotData } = useHot()
    // 品牌推荐
    const { brandData } = useBrand()
    return {
      newData,
      hotData,
      brandData
    }
  }
}
</script>

<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .price {
      color: @priceColor;
    }
  }
}
.brand-list{
  display: flex;
  li{
    flex:1;
    padding: 10px;
  }
}
</style>
